<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@include file="/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="${ctx }/js/plugs/jquery-ui-1.10.3.custom/css/mycss/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="${ctx }/js/plugs/bootstrap-3.3.0-dist/dist/css/bootstrap.css">
<link href="${ctx }/js/plugs/font-awesome-4.2.0/css/font-awesome.css" rel="stylesheet">
<link href="${ctx }/js/plugs/jquery-ui-1.10.3.custom/css/mycss/jquery-ui-1.10.3.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="${ctx }/js/plugs/jquery-ui-1.10.3.custom/js/jquery-1.10.1.js"></script>
<script type="text/javascript" src="${ctx }/js/plugs/jquery-ui-1.10.3.custom/js/jquery-ui-1.10.3.custom.js"></script>
<script type="text/javascript" src="${ctx }/js/dw/responsive-width.js"></script>
<script language="javascript" type="text/javascript" src="${ctx }/js/plugs/My97DatePickerBeta/My97DatePicker/WdatePicker.js"></script>
<link href="${ctx }/css/dw-user.css" rel="stylesheet" type="text/css" />
<link href="${ctx }/js/plugs/font-awesome-4.2.0/css/font-awesome.css" rel="stylesheet">

<title>绑定问卷</title>
<script type="text/javascript">
	
$(document).ready(function(){
	currentMenu("lotterymanager");
});

function bindSurvey(){
	var surveyId = $("input:radio[name$=surveyId]:checked").val();
	if (typeof(surveyId) == "undefined") {
		alert("请选择试卷关联");
		return;
	} else {
		var activityId = $('#activityId').val();
		var url = "/sy/lottery/bindSurveyAjax.do";
		var data="activityId="+activityId + "&surveyId=" + surveyId;
		$.ajax({
			url:url,
			data:data,
			type:"post",
			dataType:"json",
			success:function(data){
				if (data.flag == "0") {
					alert("此问卷已经和活动["+data.value+"]绑定，无法再次绑定");
				} else if(data.flag == "1"){
					alert("关联的试卷已经开始抽奖，无法再次绑定");
				} else {
					alert("绑定成功");
					window.close();
				}
			}
		});
	}
}
window.onbeforeunload = function() {  
	window.opener.location.reload(); 
};
</script>
<style type="text/css">
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default{
	background: #EFEFEF;
}
.usGroupUl{
	list-style: none;
	padding: 5px;
}
.usGroupUl li{
	list-style: none;
	font-size: 14px;
}
.usGroupUl li a{
	color: #333;
}
.new-dialog .ui-dialog-buttonset button{
	padding: 5px 10px;
}
</style>
</head>
<body>
	<div style="clear: both;"></div>
	<div id="dwBody" style="margin-top: 15px;" >
		<div id="dwBodyContent" class="bodyCenter" style="">
		<div id="dwBodyUser">
			<div class="surveyCollectMiddle">
				
				<div class="surveyCollectMiddleContent">
					<div style="padding: 25px 45px;overflow: auto;padding-top: 12px;">
							<div style="padding: 5px;color: #666565;letter-spacing: 2px;font-size: 18px;">选择问卷</div>
							
							<div class="contacts_search" style="padding: 5px;color:#666565;margin-top: 15px;" >
								<form id="formSearch" action="${ctx }/sy/lottery/surveylist.do" method="post">
								<div style="padding-left: 30px;padding-top: 8px;padding-bottom: 8px;">
									<span style="font-size: 14px;vertical-align: middle;">问卷名&nbsp;</span>
									<input type="text"  name="surveyName" value="${surveyName }" class="inputS1"/>&nbsp;&nbsp;
									<input type="hidden" id="activityId" name="activityId" value="${activityId }"/>
									<input type="submit" value="查询" class="sbtn25 sbtn25_1" style="font-size: 16px;"/>

									<div style="padding: 5px;color: #666565;text-align: right;float: right;margin-right: 20px;">
									</div>
								</div>
								</form>
								
							</div>
							
							<div style="margin-top: 15px;">
							
							<div style="padding: 5px;color:#666565; ">
								
								<div style="">
									<table class="contacts-table" width="100%" cellpadding="0" cellspacing="0">
									<tr>
										<th style="text-align: center;" width="30"></th>
										<th align="left">问卷</th>
										<th align="left">创建时间</th>
									</tr>

										<c:choose>
											<c:when test="${fn:length(surveyList) > 0}">

												<c:forEach items="${surveyList }" var="en">
													<tr>
														<td align="center">
														<input type="radio" name="surveyId"  value="${en.id }" ${bindSurveyId==en.id ? 'checked' : '' }/> 
														</td>
														<td align="left">${en.surveyName }</td>
														<td align="left"><fmt:formatDate value="${en.createDate }" pattern="yyyy年MM月dd日"/>
														</td>
													</tr>
												</c:forEach>

											</c:when>
											<c:otherwise>
												<tr>
													<td colspan="7">

														<div style="padding: 60px;font-size: 22px;text-align: center;color: #b1aeae;">还没有数据！</div>

													</td>
												</tr>
											</c:otherwise>
										</c:choose>

								</table>
								
								</div>
								
							</div>
							</div>
						<div class="contacts_search" style="padding: 5px;color:#666565;margin-top: 15px;" >
								<form id="" action="#" method="post">
								<div style="padding-left: 30px;padding-top: 8px;padding-bottom: 8px;">
	 								<button type="button" class="btn btn-default" id="saveBtn" onclick="bindSurvey()">保存</button>
									<div style="padding: 5px;color: #666565;text-align: right;float: right;margin-right: 20px;">
									</div>
								</div>
								</form>
						</div>
					</div>
					
				</div>
			</div>
			
		</div>
		</div>
	</div>

	
	
<script type="text/javascript">


resizeBodyWidth();
$("a").attr("hidefocus",true);

</script>
</body>
</html>
